<!DOCTYPE HTML>
<html>
<head>
<script src="/js-test-resources/js-test.js"></script>
<script>
description("Accessing Navigator sendBeacon methods on a closed window.");

window.jsTestIsAsync = true;

var w;
function processMessage(event) {
    if (event.data == "opened") {
        w.close();
    } else if (event.data == "closed") {
        shouldThrow("w.navigator.sendBeacon()");
        shouldBeFalse("w.navigator.sendBeacon('resources/blank.txt', 'detached-should-return false')");
        finishJSTest();
    }
}

if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.setPopupBlockingEnabled(false);
    testRunner.waitUntilDone();
}
w = window.open('/js-test-resources/window-postmessage-open-close.html');
window.addEventListener("message", processMessage, false);
</script>
